<template>
	<view>
		<view class="title">
			补充个人信息
		</view>

		<view class="input_title">
			手机
		</view>
		<input class="input_class" v-model="username" type="text" placeholder="请输入个人账号"
			placeholder-style="color:#999999;">
		<view class="input_title">
			呢称
		</view>
		<view class="input_class" style="display: flex;flex-direction: row;justify-content: space-between;">
			<input style="width: 400rpx;" v-model="nickname" placeholder="请输入昵称" placeholder-style="color:#999999;">
		</view>

		<!-- <view class="input_title">
			是否为领导层
		</view>
		<view class="input_class" style="display: flex;flex-direction: row;justify-content: space-between;">
			<u-radio-group v-model="value" shape="square" placement="row" @change="groupChange">
				<u-radio label="是" name="1"></u-radio>
				<view class="" style="width: 50rpx;">

				</view>
				<u-radio label="否" name="0"></u-radio>
			</u-radio-group>
		</view> -->

		<view class="" style="margin-top: 20rpx;font-size: 24rpx;color: #999999;">
			发送申请等待管理员同意后,可从登录页进入
		</view>


		<view class="login_btn_off all_text_center" v-if="!isCanLogin">
			申请
		</view>
		<view class="login_btn all_text_center" v-else @click="addUser()">
			申请
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				username: '',
				nickname: '',

				token: '',
				member_id: '',
				value: '0'

			}
		},
		onLoad() {
			this.token = uni.getStorageSync('chat_token') || ''
			this.member_id = uni.getStorageSync('chat_member_id') || ''
		},
		computed: {
			isCanLogin() {
				if (this.username !== '' && this.nickname !== '') {
					return true
				} else {
					return false
				}
			}
		},
		methods: {
			groupChange(n) {
				console.log('groupChange', n);
			},

			async addUser() {
				const res = await this.$myRequest({
					url: 'Chat/member_apply',
					method: 'POST',
					data: {
						member_id: this.member_id,
						token: this.token,
						username: this.username,
						nickname: this.nickname,
					},
				});
				if (res.data.code != 200) return uni.showToast({
					title: res.data.datas.msg,
					icon: 'none'
				})

				uni.showToast({
					title: res.data.datas.msg,
					icon: 'none'
				})

				setTimeout(() => {
					uni.navigateBack({
						delta: 1
					})
				}, 1000);
			}

		}
	}
</script>

<style lang="scss">
	page {
		display: flex;
		justify-content: center;
	}

	.argeement_line {
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-top: 20rpx;

		image {
			width: 26rpx;
			height: 26rpx;
		}

		.left_box {
			width: 22rpx;
			height: 22rpx;
			border-radius: 8rpx;
			border: 1rpx solid #999999;
		}

		.rigit {
			font-size: 24rpx;
			margin-left: 20rpx;

			color: #9E9E9E;
		}
	}

	.title {
		text-align: center;
		margin-top: 100rpx;
		font-size: 50rpx;
		font-weight: 500;
		color: #333333;
	}

	.input_title {
		margin-top: 100rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
	}

	.input_class {
		margin-top: 20rpx;
		width: 540rpx;
		border-bottom: 1rpx solid #D8D8D8;
		padding-bottom: 10rpx;
		padding-left: 5rpx;
	}

	.mini_text {
		font-weight: 500;
		color: #008BFE;
		font-size: 26rpx;
		display: flex;
		justify-content: flex-end;
		margin-top: 20rpx;
	}

	.login_btn {
		width: 540rpx;
		height: 80rpx;
		background: #008BFE;
		color: #ffffff;
		box-shadow: 0px 1px 4px 1px rgba(0, 0, 0, 0.4);
		border-radius: 12rpx;
		font-size: 36rpx;
		margin-top: 60rpx;
	}

	.login_btn_off {
		width: 540rpx;
		height: 80rpx;
		background: #EFEFEF;
		color: #999999;
		box-shadow: 0px 1px 4px 1px rgba(0, 0, 0, 0.4);
		border-radius: 12rpx;
		font-size: 36rpx;
		margin-top: 60rpx;
	}

	.mini_text_line {
		width: 540rpx;
		margin-top: 25rpx;
		font-weight: 500;
		color: #008BFE;
		font-size: 26rpx;
		display: flex;
		justify-content: space-between;
	}
</style>
